#
#   This file is part of cmcc-homeofficeclient
#

### Compile Options
CONFIG += c++17
CONFIG += separate_debug_info
CONFIG += utf8_source
CONFIG += no_lflags_merge

QMAKE_CFLAGS += -std=c99
QMAKE_CXXFLAGS += -std=c++0x
QMAKE_CXXFLAGS += -Wno-deprecated-copy
linux {
    load(ccache)
    # suppress the default RPATH if you wish
    QMAKE_LFLAGS_RPATH =
    # add your own with quoting gyrations to make sure $ORIGIN gets to the command line unexpanded
    QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'"
}

equals(TEMPLATE, "lib") {
    win32: CONFIG += skip_target_version_ext
    unix: CONFIG += unversioned_libname
}

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
DEFINES += QT_DEPRECATED_WARNINGS

### Build Directories
DESTDIR = $${PWD}/build
BUILDDIR = $${DESTDIR}/.tmp/$${TARGET}

CONFIG(debug, debug|release) {
    win32: BUILDDIR = $${BUILDDIR}/win32-debug
    linux: BUILDDIR = $${BUILDDIR}/linux-debug
} else {
    win32: BUILDDIR = $${BUILDDIR}/win32-release
    linux: BUILDDIR = $${BUILDDIR}/linux-release
}

UI_DIR += $${BUILDDIR}
MOC_DIR += $${BUILDDIR}
RCC_DIR += $${BUILDDIR}
OBJECTS_DIR += $${BUILDDIR}/obj

INCLUDEPATH += $${UI_DIR}
LIBS += -L $${DESTDIR}

### Update Translations
!isEmpty(TRANSLATIONS) {
    #CONFIG += embed_translations
    CONFIG(embed_translations) {
        #QM_FILES_RESOURCE_PREFIX = :/i18n/
    } else {
        #CONFIG += lrelease
        CONFIG(lrelease) {
            #QM_FILES_INSTALL_PATH = $${DESTDIR}/translations
        } else {
            QMAKE_EXTRA_COMPILERS += lrelease
            lrelease.input         = TRANSLATIONS
            lrelease.output        = ${QMAKE_FILE_BASE}.qm
            lrelease.commands      = $$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT}
            lrelease.CONFIG       += no_link target_predeps
        }

        # Install Translation Files
        translations.path = $${DESTDIR}/translations
        translations.files = ?*.qm
        win32 {
            build_pass:CONFIG(lrelease) {
                CONFIG(debug, debug|release): translations.files = debug/?*.qm
                CONFIG(release, debug|release): translations.files = release/?*.qm
            }
        }
        INSTALLS += translations
    }
}
